package logic

import (
	"context"
	"house/models"

	"house/house"
	"house/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateUserLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUpdateUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateUserLogic {
	return &UpdateUserLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 审核用户权限
func (l *UpdateUserLogic) UpdateUser(in *house.UpdateUserReq) (*house.UpdateUserResp, error) {
	// todo: 审核用户权限

	var err error

	u := models.User{
		Nick:        in.Nick,
		RealName:    in.RealName,
		IdCard:      in.IdCard,
		IdCardFrond: in.IdCardFrond,
		IdCardSide:  in.IdCardSide,
		Status:      int(in.Status),
	}
	err = u.First(int(in.UserId))
	if err != nil {
		logx.Error("审核未通过")
		return nil, err
	}
	return &house.UpdateUserResp{
		Id: int64(u.ID),
	}, nil
}
